import { createRouter, createWebHashHistory } from 'vue-router'
// 公共布局组件
import Layout from '@/views/Layout'
// 公共布局的第一个子路由
import Home from '@/views/Home'
import Category from '@/views/Category'
// 二级路由
import CategorySub from '@/views/Category/sub.vue'
import Goods from '@/views/Goods'
const Login = () => import('@/views/Login')
const Test = () => import('@/views/Test')
const LoginCallBack = () => import('@/views/Login/callback')
const Cart = () => import('@/views/Cart')
const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: Home
      }, {
        path: '/category/:id',
        component: Category
      }, {
        path: '/category/sub/:id',
        component: CategorySub
      }, {
        path: '/goods/:id',
        component: Goods
      }, {
        path: '/Cart',
        component: Cart
      }
    ]
  },
  // 登录
  {
    path: '/login',
    component: Login
  },
  // 测试
  {
    path: '/test',
    component: Test
  },
  // qq登录
  {
    path: '/login/callback',
    component: LoginCallBack
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
